package com.bookcloud.java21.chapter2.逻辑运算符_布尔逻辑2_13;

/** 2.13逻辑运算符—布尔逻辑 */
public class Lesson213 {
  public static void main(String[] args) {
    /*
    一、逻辑的运算符的种类：
      1.逻辑与运算符&&
      2.逻辑或运算符||
      3.逻辑非运算符!
      4.逻辑异或运算符^

     */
    // 逻辑与运算符&&
    boolean a = false;
    boolean b = true;
    boolean c = a && b;
    System.out.println("c:" + c);
    // 具体的应用
    // 1.判断一个数是否为偶数
    int num = 9;
    boolean isEven = (num % 2 == 0) && (num > 0);
    System.out.println("isEven:" + isEven);
    //  逻辑与运算符||
    boolean d = a || b;
    System.out.println("d:" + d);
    // 逻辑非运算符!
    boolean e = !a;
    System.out.println("e:" + e);
    // 逻辑异或运算符^
    boolean f = a ^ b;
    System.out.println("f:" + f);
  }
}
